package com.ng.finance.api.controller;

import com.baomidou.mybatisplus.plugins.Page;
import com.ng.finance.api.entity.WechatUser;
import com.ng.finance.api.service.WechatUserService;
import com.ng.finance.common.pojo.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author 83673
 * @since 2018-09-13
 */
@RestController
@RequestMapping("/api/wechatUser")
public class WechatUserController {
    @Resource
    WechatUserService wechatUserService;

    /**
     * 获取微信openId
     *
     * @param code
     * @return
     */
    @GetMapping(value = "getCode")
    public Result getCode(@NotNull @RequestParam String code) {
        return wechatUserService.getCode(code);

    }

    /**
     * 绑定
     */
    @PostMapping(value = "binDingWechatUser")
    public Result binDingWechatUser(@Valid WechatUser wechatUser) {
        return wechatUserService.binDingWechatUser(wechatUser);
    }


    /**
     * 获取首页
     */
    @GetMapping(value = "getFinanceIndex")
    public Result getFinanceIndex() {
        return wechatUserService.getFinanceIndex();
    }

    /**
     * 获取首页列表
     */
    @GetMapping(value = "getFinanceIndexList")
    public Result getFinanceIndexList(@NotNull @RequestParam String payTime, Page page) {
        return wechatUserService.getFinanceIndexList(payTime, page);
    }


    /**
     * 查询所有用户
     */
    @GetMapping(value = "selectAllUser")
    public Result selectAllUser() {
        return wechatUserService.selectAllUser();
    }

}

